package com.scm.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @ClassName LoginInterceptor
 * @Description TODO
 * @Author Xu
 * @Date 2021/7/5 23:05
 * @Version 1.0
 **/
public class LoginInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        String account = (String) request.getSession().getAttribute("account");
        if (account == null){
            response.sendRedirect(request.getContextPath()+"/login.html");
            return false;
        }
        return true;
    }
}
